package server;



import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;

/**
 * A TCP socket. Uses Java socket implementation.
 */
public class DefaultTCPSocket implements GenericSocket {

	private Socket socket;
	
	public DefaultTCPSocket (Socket socket) {
		this.socket = socket;
	}
	
	
	
	@Override
	public InputStream getInputStream() {
		try {
			return socket.getInputStream();
		} catch (IOException e) {
			e.printStackTrace();
			return null;
		}
	}

	@Override
	public OutputStream getOutputStream() {
		try {
			return socket.getOutputStream();
		} catch (IOException e) {
			e.printStackTrace();
			return null;
		}
	}

	@Override
	public void close() {
		try {
			socket.close();
		} catch (IOException e) {
			//do nothing
			e.printStackTrace();
		}
		
	}
	
	@Override
	public int getLocalPort () {
		return socket.getLocalPort();
	}

	@Override
	public int getPort() {
		return socket.getPort();
	}
	
	@Override
	public InetAddress getIPAddress() {
		return socket.getInetAddress();
	}
	
	@Override
	public InetAddress getLocalIPAddress() {
		return socket.getLocalAddress();
	}

}
